#include "stdafx.h"

#include "SkinFactory.h"

#include "SkinTable.h"
#include "SkinControl.h"
#include "SkinFont.h"
#include "SkinColumn.h"
#include "SkinMode.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


CSkinFactory::CSkinFactory()
{
}

CSkinFactory::~CSkinFactory()
{
}

CSkinElement* CSkinFactory::CreateElement(CString strNodeName, CSkinElement * pParent)
{
	CSkinElement * pNewElement = NULL;

	if (strNodeName == _T("table"))
	{
		pNewElement = new CSkinTable;
	}	
	else if ( strNodeName == _T("control") ||  strNodeName == _T("button") )
	{
		pNewElement = new CSkinControl;
	}
	else if (strNodeName == _T("font"))
	{
		pNewElement = new CSkinFont;
	}
	else if (strNodeName == _T("tr"))
	{
		pNewElement = new CSkinRow;
	}
	/*else if (strNodeName == "tda")
	{
		CSkinColumn * pSFTD = new CSkinColumn;
		CSkinAlphaColumn * pSFTR = static_cast<CSkinAlphaColumn*>(pSFTD);
		pNewElement = static_cast<CSkinAlphaColumn*>(pSFTR);
	}*/
	else if (strNodeName == _T("td"))
	{
		CSkinColumn * pSFTD = new CSkinColumn;
		CSkinRow * pSFTR = static_cast<CSkinRow*>(pSFTD);
		pNewElement = static_cast<CSkinRow*>(pSFTR);
	}

	if(pNewElement){
		// KHE
		pNewElement->SetTemplateID( pParent->GetTemplateID() );

		pNewElement->SetParent( pParent );
	}

	return pNewElement;
}